<template>
	<view class="" @click.stop="moreIndex = -1">
		<view class="content">
			<view class="grant-staus">
				<view @click="grantClick(item)" class="grant-item" :class="{active:value == item.value}"
					v-for="(item,index) in grantStaus" :key="index">
					{{item.name}}
					<image v-if="value == item.value" src="https://qiyeji.oss-cn-beijing.aliyuncs.com/pet/service/sanjiaoxing.png" mode=""></image>
				</view>
			</view>
			<view class="content-cont">
				<view v-for="(item,index) in list" class="item" :key="index">
					<view class="item-left">
						<view class="left-title text-cut">
							{{item.name}}
						</view>

						<view class="left-item">
							<view class="left-item-title">服务商：</view>
							<view class="left-item-value text-cut">{{item.teamName}}</view>
						</view>
						<view class="left-item">
							<view class="left-item-title">总授权次数：</view>
							<view class="left-item-value text-cut">{{item.total}}次</view>
						</view>
						<view class="left-item">
							<view class="left-item-title">已发放次数：</view>
							<view class="left-item-value text-cut">{{item.useNum}}次</view>
						</view>
						<view class="left-item" v-if="item.iStatus == 3">
							<view class="left-item-title">状态：</view>
							<view class="left-item-value text-cut">{{item.type == 'MCH' ? '已发放': '已核销'}}</view>
						</view>
						<view class="left-item" v-else>
							<view class="left-item-title">状态：</view>
							<view class="left-item-value text-cut">{{item.iStatusStr }}</view>
						</view>
						
						
					</view>
					<view class="">
						<view class="item-bottom">
							<view v-if="!item.iStatus" class="item-bottom-btn" style="width: 132rpx;" @click="toPage(`/pagesPet/pages/service/saler/serve/grant?item=${encodeURIComponent(JSON.stringify({
							data:item,
							type:'USER',
							pId:item.issueId
						}))}`)">
								发放
							</view>
							<view style="width: 184rpx;background: #fafafa;color: #000;" class="item-bottom-btn"
								@click="handleGrant(item)">
								发放记录
							</view>
						</view>
					</view>
				</view>
				<view class="none">
					没有更多了～
				</view>
			</view>
		</view>

		<authRecord ref='authRecord'></authRecord>
	</view>
</template>

<script>
	import authRecord from "./authRecord"
	import showModal from "@/components/show-modal1"
	export default {
		components: {
			showModal,
			authRecord
		},
		props: {
			value: String,
			list: Array
		},
		data() {
			return {
				moreIndex: -2,
				moreList: [{
						name: '上线'
					},
					{
						name: '下线'
					},
					{
						name: '发放',
						type: "grant"
					},
					{
						name: '授权记录',
						type: "record"
					}
				],
				grantStaus: [{
						name: '已发放',
						value: 1
					},
					{
						name: '未发放',
						value: 0
					}
				]
			}
		},
		methods: {
			toPage(url) {
				uni.navigateTo({
					url
				})
			},
			grantClick(item, index) {
				this.$emit('input', item.value)
				this.$parent.init()
			},
			handleGrant(item){
				this.$refs.authRecord.handleOpen({
					type:'other',
					item:item
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.bottom-box-btn {
		position: fixed;
		bottom: 135rpx;
		left: 50%;
		transform: translateX(-50%);
		background: var(--primaryBg);
		box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0, 0, 0, 0.03);
		border-radius: 40rpx;
		border: 4rpx solid #FFFFFF;
		width: 202rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;

		image {
			width: 29rpx;
			height: 29rpx;
			margin-right: 12rpx;
		}

		view {
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			font-size: 28rpx;
			color: var(--btnColor);
			line-height: 40rpx;
			text-align: center;
			font-style: normal;
		}
	}

	.content {
		flex: 1;
		position: relative;
		width: 100%;
		background: #F8F8F8;
		border-radius: 32rpx 32rpx 0rpx 0rpx;
		box-sizing: border-box;

		top: -28rpx;

		.content-cont {
			padding: 16rpx;
		}

		.item {
			width: 100%;
			background: #FFFFFF;
			border-radius: 12rpx;
			margin-bottom: 16rpx;
			padding: 22rpx 24rpx;
			box-sizing: border-box;

			.item-left {
				flex: 1;

				.left-title {
					margin-bottom: 24rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 32rpx;
					color: var(--h1Color);
					line-height: 45rpx;
				}

				.left-item {
					width: 100%;
					display: flex;
					align-items: center;
					overflow: hidden;
					margin-bottom: 12rpx;

					&:last-child {
						margin-bottom: 0;
					}

					view {
						// font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						color: var(--h2Color);
						line-height: 40rpx;
					}

					.left-item-icon {
						margin-right: 12rpx;
						width: 26rpx;
						height: 26rpx;
					}

					.left-item-title {
						width: 200rpx;

					}

					.left-item-value {
						flex: 1;
					}
				}
			}

			.item-bottom-box {
				margin-top: 48rpx;

				.more {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 26rpx;
					color: var(--h3Color);
					line-height: 37rpx;
					text-align: left;
					font-style: normal;
					position: relative;

					.more-list {
						top: 50rpx;
						position: absolute;
						z-index: 99;
						width: 200rpx;
						height: 375rpx;
						padding: 0 25rpx;
						background: #FFFFFF;
						box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0, 0, 0, 0.03);
						border-radius: 12rpx;
						border: 1rpx solid #EEEEEE;

						.more-item {
							display: flex;
							align-items: center;
							justify-content: center;
							height: 93rpx;
							border-bottom: 1rpx solid #EEEEEE;
							font-family: PingFangSC, PingFang SC;
							font-weight: 400;
							font-size: 26rpx;
							color: var(--h1Color);
							line-height: 37rpx;
							text-align: left;
							font-style: normal;

							&:last-child {
								padding-bottom: 0;
								border-bottom: none;
							}
						}
					}
				}
			}

			.item-bottom {
				display: flex;
				align-items: center;
				justify-content: flex-end;

				.item-bottom-btn {
					margin-left: 12rpx;
					width: 142rpx;
					background: var(--primaryBg);
					border-radius: 12rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 26rpx;
					color: var(--btnColor);
					line-height: 64rpx;
					text-align: center;
				}
			}
		}

		.none {
			width: 100%;
			text-align: center;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			color: var(--h4Color);
			line-height: 33rpx;
			margin-top: 40rpx;
		}
	}

	.grant-staus {
		width: 100%;
		height: 108rpx;
		background: #FFFFFF;
		border-radius: 32rpx 32rpx 0rpx 0rpx;
		display: flex;
		align-items: center;
		padding: 16rpx 24rpx;

		.grant-item {
			width: 142rpx;
			height: 56rpx;
			background: #F8F8F8;
			border-radius: 28rpx;

			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 26rpx;
			color: var(--h2Color);
			line-height: 37rpx;
			text-align: center;
			font-style: normal;
			position: relative;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-right: 16rpx;

			image {
				position: absolute;
				left: 50%;
				bottom: -10rpx;
				transform: translateX(-50%);
				width: 24rpx;
				height: 12rpx;
			}

			&.active {
				width: 142rpx;
				height: 56rpx;
				color: var(--h1Color);
				background: var(--primaryBg);
				border-radius: 28rpx;
			}
		}

	}
</style>